<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="content-type">
  <title>cmdin</title>
</head>
<body>
<span style="font-family: monospace;"><br>
<br>
</span>The cmd_interface is virtual abstract class that can be used as
an interface to COID framework server.<br>
<br>
<h4>Access mutex locking</h4>
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp; void
<span style="font-weight: bold;">mutex_wrlock</span>();</span><br
 style="font-family: monospace;">
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp; void
<span style="font-weight: bold;">mutex_rdlock</span>();</span><br
 style="font-family: monospace;">
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp; void
<span style="font-weight: bold;">mutex_unlock</span>();<br>
<br>
</span>These methods are used mainly in <span
 style="font-family: monospace;">accept_connect_auto</span> and <span
 style="font-family: monospace;">accept_spawn methods</span> or in
additional threads that service runs, to temporarily block access for
remote clients. Macro CMDIN_GUARD, that uses the <span
 style="font-family: monospace;">cmd_interface::GUARD</span> class,
wraps the usage so that it's exception-safe.<br>
<br>
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp; //guarded
section</span><br>
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; CMDIN_GUARD(_cmdin);<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; ...<br>
&nbsp;&nbsp;&nbsp; }<br>
<br>
</span>
<h4>Using system log</h4>
<span style="font-family: monospace;"></span><br
 style="font-family: monospace;">
<span style="font-family: monospace;"></span><span
 style="font-family: monospace;">&nbsp;&nbsp;&nbsp; binstream&amp;
<span style="font-weight: bold;">set_msg</span>( uchar msgclass, uchar
verb );</span><br style="font-family: monospace;">
<br style="font-family: monospace;">
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp; void <span
 style="font-weight: bold;">mprintf</span>(
uchar msgclass, const char* format, ... )</span><br
 style="font-family: monospace;">
<span style="font-family: monospace;"></span><span
 style="font-family: monospace;"><br>
&nbsp;&nbsp;&nbsp; binstream&amp; <span style="font-weight: bold;">post_alert</span>(uchar
verbose)</span><br style="font-family: monospace;">
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp; binstream&amp;
<span style="font-weight: bold;">post_critical</span>(uchar verbose)</span><br
 style="font-family: monospace;">
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp; binstream&amp;
<span style="font-weight: bold;">post_error</span>(uchar verbose)</span><br
 style="font-family: monospace;">
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp; binstream&amp;
<span style="font-weight: bold;">post_warning</span>(uchar verbose)</span><br
 style="font-family: monospace;">
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp; binstream&amp;
<span style="font-weight: bold;">post_info</span>(uchar verbose)<br>
<br style="font-family: monospace;">
</span>Only the <span style="font-family: monospace;">set_msg</span>
method is actually present on the server, the other methods are just
helper functions.<br>
The set_msg method takes a message type <span
 style="font-family: monospace;">msgclass</span> as the first argument.
Available types are listed in the LOGMSG structure in
coid/coidsvc/cmdin.h header file. The second parameter is verbosity
level of the message, where 0 is the highest significance. Return value
is a reference to <a href="binstream.html"><span
 style="font-family: monospace;">binstream</span></a> object that can
be used to push the actual message to. The message must be properly
ended, i.e. either <span style="font-family: monospace;">flush()</span>
method must be called on the binstream object or EOM should be pushed
into it:<br>
<br>
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp; post_info(0)
&lt;&lt; "something strange has happenend in slot " &lt;&lt; slotnum
&lt;&lt; ". error: " &lt;&lt; opcd_formatter(e) &lt;&lt; EOM;</span><br>
<br>
The <span style="font-family: monospace;">mprintf</span> method takes
a message type as the first argument. Remaining arguments are the same
as in <span style="font-family: monospace;">printf</span>. This method
automatically ends (flushes) the message.<br>
<br>
<br>
<h4>Getting info</h4>
These methods are used to retrieve and set information about object
managed by the COID framework. This information is normally used in
system log and when displaying data of the managed objects in the
management console.<br>
<br style="font-family: monospace;">
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;
uint&nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">get_id</span>()
const;<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span>Get object id, by which
the framework server recognizes it.<br>
<br>
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;
uint&nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">get_superior_id</span>()
const;<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span>Get id of the parent
object.<span style="font-family: monospace;"><br>
</span><span style="font-family: monospace;"></span><br
 style="font-family: monospace;">
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp; const char*
<span style="font-weight: bold;">short_name</span>() const;</span><br
 style="font-family: monospace;">
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp; const char*
<span style="font-weight: bold;">class_name</span>() const;<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span>Get your short name and
class name. Short name is used in logs and console, class name is name
of the service.<span style="font-family: monospace;"><br
 style="font-family: monospace;">
</span><br style="font-family: monospace;">
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;
<a href="opcd_type.html">opcd</a>&nbsp;&nbsp;&nbsp; <span
 style="font-weight: bold;">get_name</span>( charstr&amp; name ) const;</span><br
 style="font-family: monospace;">
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;
<a href="opcd_type.html">opcd</a>&nbsp;&nbsp;&nbsp; <span
 style="font-weight: bold;">set_name</span>( const charstr::token&amp;
name );</span><br style="font-family: monospace;">
<br>
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; </span>Get and set object's custom name.<br>
<br>
<br>
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;
char*&nbsp;&nbsp; <span style="font-weight: bold;">get_server_address</span>(
charstr&amp; buf ) const;<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span>Get ip address of the
server.<span style="font-family: monospace;"><br
 style="font-family: monospace;">
</span><br>
<br style="font-family: monospace;">
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;
<a href="opcd_type.html">opcd</a>&nbsp;&nbsp;&nbsp; <span
 style="font-weight: bold;">list_devices</span>( const
token&amp; classname, const version&amp; ver, const token&amp; name,
dynarray&lt;uint&gt;&amp; devices ) const;</span><br
 style="font-family: monospace;">
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;
<a href="opcd_type.html">opcd</a>&nbsp;&nbsp;&nbsp; <span
 style="font-weight: bold;">list_conn_devices</span>(
const token&amp; classname, const version&amp; ver, const token&amp;
name, dynarray&lt;uint&gt;&amp; devices ) const;<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span>List object id's of
objects that match the criteria.
The criteria can be class (service) name, service version and object's
name. The second variant lists only objects that exist under current
connection.<span style="font-family: monospace;"><br
 style="font-family: monospace;">
</span><br>
<br style="font-family: monospace;">
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;
<a href="opcd_type.html">opcd</a>&nbsp;&nbsp;&nbsp; <span
 style="font-weight: bold;">get_device_info</span>( uint id,
charstr&amp; service,
version&amp; ver, charstr&amp; name ) const;<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span>Get information about
specified object.<span style="font-family: monospace;"><br>
<br>
<br style="font-family: monospace;">
</span><span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;
char*&nbsp;&nbsp; <span style="font-weight: bold;">get_working_dir</span>(
charstr&amp; buf ) const;<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span>Get path to working
directory of current service. Trailing slash appended.<br>
<br>
<br style="font-family: monospace;">
<span style="font-family: monospace;"></span><span
 style="font-family: monospace;"></span><span
 style="font-family: monospace;">&nbsp;&nbsp;&nbsp;
<a href="opcd_type.html">opcd</a>&nbsp;&nbsp;&nbsp; <span
 style="font-weight: bold;">get_object_address</span>( netaddr&amp;
addr, uint* obj
) const;<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span>Return global object
address, comprising of server ip
address and object id. This can be used for shared connections to the
object.<br>
<br style="font-family: monospace;">
<span style="font-family: monospace;"></span><br
 style="font-family: monospace;">
<span style="font-family: monospace;"></span><span
 style="font-family: monospace;">&nbsp;&nbsp;&nbsp;
<a href="opcd_type.html">opcd</a>&nbsp;&nbsp;&nbsp; <span
 style="font-weight: bold;">get_method_desc</span>( uint id, const
ServiceDescriptor::MethodDesc** pdesc, uint* nmeth ) const;<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span>Get method description
table for given object. The object id must specify object that is of
ServiceInstanceCoid class.<br>
<br>
<br>
<h4>Options</h4>
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;
<a href="opcd_type.html">opcd</a>&nbsp;&nbsp;&nbsp; <span
 style="font-weight: bold;">set_option</span>( uint optid, int value );</span><br
 style="font-family: monospace;">
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;
<a href="opcd_type.html">opcd</a>&nbsp;&nbsp;&nbsp; <span
 style="font-weight: bold;">get_option</span>( uint optid, int* value )
const;<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span>Set or retrieve runtime
options of object. Currently <span style="font-family: monospace;">optid</span>
can be only OPTION_ALLOW_SHARED_ACCESS, that should be set to nonzero
if object wants to allow framework server to estabilish shared
connections to this object, if client requests it using <span
 style="font-family: monospace;">connect_shared()<br
 style="font-family: monospace;">
</span><br style="font-family: monospace;">
<span style="font-family: monospace;"><br>
<br>
</span>
<h4>Other<span style="font-family: monospace;"></span></h4>
<h4><span style="font-family: monospace;"></span></h4>
<br style="font-family: monospace;">
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;
<a href="opcd_type.html">opcd</a>&nbsp;&nbsp;&nbsp; <span
 style="font-weight: bold;">dispatch_method</span>( uint obj, const
token&amp;
method, binstream&amp; parinout );<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span>Dispatch method call to
another object in the system.<span style="font-family: monospace;"><br
 style="font-family: monospace;">
</span><br>
<br style="font-family: monospace;">
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;
<a href="opcd_type.html">opcd</a>&nbsp;&nbsp;&nbsp; <span
 style="font-weight: bold;">spawn_thread</span>( t_thread_fnc start,
void* arg,
const char* name );<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span>Spawn new thread owned by
the object.<span style="font-family: monospace;"><br>
<br style="font-family: monospace;">
</span><span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;
<a href="opcd_type.html">opcd</a>&nbsp;&nbsp;&nbsp; <span
 style="font-weight: bold;">free_threads</span>();<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span>Free all threads owned by
the object.<br>
<br style="font-family: monospace;">
<span style="font-family: monospace;"></span><br
 style="font-family: monospace;">
<span style="font-family: monospace;"></span><span
 style="font-family: monospace;"></span><span
 style="font-family: monospace;"><br style="font-family: monospace;">
</span><br style="font-family: monospace;">
<span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;
<a href="opcd_type.html">opcd</a>&nbsp;&nbsp;&nbsp; <span
 style="font-weight: bold;">set_identity</span>( const account_id&amp;
acid );<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span>Set identity of the
object in the framework. Access rights to framework depend on that.<span
 style="font-family: monospace;"><br>
</span>
</body>
</html>
